package org.gordonframework.site.transitions {
	import org.gordonframework.site.transitions.GTransition;
	import org.gordonframework.site.views.GView;	

	/**
	 * @author sampet
	 */
	public class GAccordion extends GTransition {

		private var duration:Number;
		private var collapsedHeight:Number;		private var expandedHeight:Number;

		public function GAccordion(collapsedHeight:Number = 20, expandedHeight:Number = 100, duration:Number = 0.5) {
			this.collapsedHeight = collapsedHeight;			this.expandedHeight = expandedHeight;
			this.duration = duration;
		}

		override public function addView(view:GView):void {
			super.addView( view );
			view.visible = true;
			view.height = collapsedHeight;
			layout( );
		}

		private function layout():void {
			var y:Number = 0;
			for each(var view:GView in views) {
				view.y = y;
				y = view.bottom;
			}			
		}

		override protected function showView():void {
			if(oldView) {
				oldView.height = collapsedHeight;
			}
			currentView.height = expandedHeight;
			layout( );
			showViewComplete();
		}
	}
}
